<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="false">
			<!-- <block slot="backText">返回</block> -->
			<block slot="content">账号管理</block>
		</cu-custom>
		<view class="cu-bar bg-white margin-top solid-bottom">
			<view class="action">
				<text class="cuIcon-title text-green"></text>
				<text>请选择一个账号登录</text>
			</view>
			<view class="action" @click="handleEditor">
				<button class="cu-btn cu-tag  line-blue round"> {{editor ? '完成' : '编辑'}} </button>
			</view>
		</view>
		
		<view class="cu-list  menu-avatar  account-list" >
			<view class="cu-item" hover-class="list-hover" v-for="(item, index) in userList" :key="index" @click="handleClick(item, index)">
				<view class="cu-avatar round lg bg-blue light">{{item.Name.slice(0, 1)}}</view>
				<view class="content">
					<view class="text-cut">{{item.Name}}</view>
					<view class="text-grey text-sm flex"> <view class="text-cut">{{hiddenIdCard(item.IdentityNo)}}</view></view>
				</view>
				<view class="action" v-if="editor" @click.stop="removeUser(index)">
					<view class="cuIcon-roundclosefill text-red"></view>	
				</view>
	
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item" hover-class="list-hover">
				<view class="content text-blue"  @click="toLogin">
					<text class="cuIcon-roundadd" ></text>
					<text>添加账号</text>
				</view>
			</view>
		</view>	
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				editor: false,
				isLogin: true,
				activeIndex: 0,
				// userList: this.$store.state.user.userList,
				userList1: [
					{
						"Userid": "NC5lUhB67kZQH6Ovw1WY35rWTnl6DuqD",
						"Name": "鲁大师",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					},
					{
						"Userid": "NC5lUhB67kZQH6Ovq23WY35rWTnl6DuqD",
						"Name": "小老弟",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					},
					{
						"Userid": "NC5lUhB67kZQH6Ovq1WY35rWTnl6DuqD",
						"Name": "小明",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					},
					{
						"Userid": "NC5lUhB67kZQH6Ovq1WY35rWTnl6DuqD",
						"Name": "代理商",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					},
					{
						"Userid": "NC5lUhB67kZQH6Ovq1WY35rWTnl6DuqD",
						"Name": "小明",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					},
					{
						"Userid": "NC5lUhB67kZQH6Ovq1WY35rWTnl6DuqD",
						"Name": "德鲁克",
						"IdentityNo": "371726199108057664",
						"IsLimit": true
					}
				],
			}
		},
		onLoad(){
			
		},
		computed: {
			userList() {
				return this.$store.state.user.userList
			}
		},
		created () {
			let s = this.$store.state.user.userList
			console.log('s', s)
		},
		methods: {
			hiddenIdCard(n) {
				n += '';
				return n.slice(0, 6) + '****' + n.slice(14)
			},
			removeUser(index) {
				console.log('index', index)
				this.$store.commit('user/removeUser', {index})
			},
			handleEditor() {
				this.editor = !this.editor;
			},
			handleClick(item, index) {
				uni.navigateTo({
					url:'/pages/recognition/recognition',
					success: () =>  {
						// this.$store.commit('user/addUserList', item)
						this.$transmit.set({
							from: 'account',
							to: 'recognition',
							data: this.item
						})
					}
				})
			},
			toLogin() {				
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

